// https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/solution/gu-piao-wen-ti-python3-c-by-z1m


int maxProfit(int* prices, int pricesSize){
    if (pricesSize <= 1) return 0;
    int i, *dp = malloc(sizeof(int)*pricesSize);//表示前i天的最大利润
    for (i = 0; i < pricesSize; i++)//初始条件
        dp[i] = 0;

    int min_price = prices[0]; 
    for (i = 1; i < pricesSize; i++) {
        min_price = MIN(min_price, prices[i]);			
        dp[i] = MAX(dp[i-1], prices[i] - min_price);	//转移方程
    }
    return dp[i-1];
}